package com.woniuxy.portal.utils;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.stereotype.Component;

/**
 * @author yellow Docter
 * @date 2024-10-22
 * @desc 蜗牛创想：www.woniuxy.com
 */
@Component
public class EmailUtils {

    @Autowired
    private JavaMailSender javaMailSender;

    public void  sendEmail(String toEmail,String code) {
        //创建邮件对象
        SimpleMailMessage message = new SimpleMailMessage();
        //设置邮件属性
        message.setSubject("蜗牛书城的验证码");

        String text = "蜗牛书城用于注册，验证码是:" + code;
        message.setText(text);

        //发件人
        message.setFrom("441650416@qq.com");
        //收件人
        message.setTo(toEmail);

        //发送邮件
        javaMailSender.send(message);
    }

}
